package etrgo

type DBConf struct {
	DbType string
	ConStr string
}

type Setting struct {
	AppPath     string
	TemplateDir string
	DbConf      DBConf
	ImgDir      string
	ImgURL      string
}

const (
	DbConString = "db_constr"
	DbConType   = "db_type"
	TemplateDir = "template_dir"
	ImgDir      = "image_dir"
	ImgURL      = "image_url"
)

var Configuration Setting

func (conf *Setting) Init(configFile string) bool {
	cf, err := LoadConfig(configFile)
	if err != nil {
		Error("failed to load the configuration file[%s].", configFile)
		return false
	}
	conf.DbConf.ConStr = cf.String(DbConString)
	conf.DbConf.DbType = cf.String(DbConType)
	conf.TemplateDir = cf.String(TemplateDir)
	conf.ImgDir = cf.String(ImgDir)
	conf.ImgURL = cf.String(ImgURL)
	return true
}
